package com.dhl.iterator;

import java.util.Iterator;
import java.util.List;

/**
 * @title: OutputImpl
 * @Author danghailiang
 * @Date: 2022/8/20 16:37
 * @Version 1.0
 */
// 输出实现
public class OutputImpl {
    /**
     * 学院集合
     */
    private List<College> college;

    public OutputImpl (List<College> college){
        this.college = college;
    }

    /**
     * 打印输出
     */
    public void printCollege(){
        Iterator<College> iterator = college.iterator();
        while (iterator.hasNext()){
            College college = iterator.next();
            System.out.println("-----------" + college.getName() + "-----------");
            printDepartment(college.createIterator());
        }
    }

    private void printDepartment(com.dhl.iterator.Iterator iterator){
        while (iterator.hasNext()){
            Department department = (Department)iterator.next();
            System.out.println(department.getName());
        }
    }
}
